package com.woniuxy.controller;

import com.woniuxy.entity.Food;
import com.woniuxy.service.FoodService;
import com.woniuxy.util.ResponseData;
import com.woniuxy.util.ResponseEnum;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.nio.file.FileStore;
import java.util.List;

/**
 * @BelongsProject: pigTrotterStore
 * @BelongsPackage: com.woniuxy.controller
 * @Author: Quan
 * @Date: 2025/3/8 12:06
 */
@AllArgsConstructor
@RestController
@RequestMapping("/food")
public class FoodController {
	FoodService foodService;

	@GetMapping("/queryAll")
	public ResponseData<?> queryAll(HttpServletRequest request) {
		List<Food> foods = foodService.queryAll();
		System.out.println(request.getHeader("Host"));
		return ResponseData.ok(foods);
	}

	@GetMapping("/queryFoodDetail/{id}")
	public ResponseData<?> queryFoodDetail(@PathVariable("id") Integer id) {
		Food food = foodService.queryFoodDetail(id);
		if (food == null) {
			return ResponseData.fail(ResponseEnum.SYS_BUSY);
		}
		return ResponseData.ok(food);
	}
}











